<template>
  <div class="cusha">
    <div class="content_title">
      <span class="content_text">粗纱</span>
      <img
        class="content_img"
        src="@/assets/img/chart/cusha.png"
        alt=""
        srcset=""
      />
    </div>
    <div class="cusha_body">
      <div
        v-for="(item, index) in cushaData.cushaDataRow1Data"
        :key="index + 'a'"
        class="cusha_item"
      >
        <div v-if="index == 3">
          <div class="dongli" @click="clickHandleDl('cusha_' + index)">
            <img src="@/assets/img/dongliguis.png" alt="" srcset="" />
          </div>
        </div>
        <div v-if="index == 13">
          <div class="dongli1" @click="clickHandleDl('cusha_' + index)">
            <img src="@/assets/img/dongligui.png" alt="" srcset="" />
          </div>
        </div>
        <div @click="clickHandle(item)">
          <cusha :data="item"></cusha>
        </div>
      </div>
    </div>
    <!-- 粗纱弹窗控件 -->
    <cushaDialog ref="cushaDialog"></cushaDialog>
    <!-- 动力柜弹窗控件 -->
    <dongliDialog ref="dongliDialog"></dongliDialog>
  </div>
</template>

<script>
import dongliDialog from '../qcs/dialog/dialog_dongli/index';

import cushaDialog from '../qcs/dialog/dialog_cusha/index';
import cusha from '../qcs/cusha';
import COMMON from '@/utils/common';
import dongLiMenu from '../data/dongli.json';
import dongliItem from '../data/dongliItem.json';
export default {
  name: 'CuSha',
  props: {
    msg: String
    // 是否嵌套在弹窗内
  },
  components: {
    dongliDialog,
    cusha,
    cushaDialog
  },
  data() {
    return {
      cushaData: {
        // 1-14
        cushaDataRow1Data: [],
        // 15-16
        cushaDataRow2Data: [],
        dongLiMenu: {},
        dongLiItem: {}
      }
    };
  },
  created() {
    this.dongLiMenu = dongLiMenu;
    this.dongLiItem = dongliItem;
  },
  computed: {
    txcsomlGroupState() {
      return this.$store.state.workshop.txcsomlGroupState;
    }
  },
  watch: {
    txcsomlGroupState: {
      immediate: true,
      handler(val) {
        this.cushaData.cushaDataRow1Data = COMMON.devSnFilter(val.data, 1, 16);
      }
    }
  },
  methods: {
    closeHandle() {
      this.$parent.$parent.$parent.closeParentHandle();
    },
    clickHandle(item) {
      // 旧粗纱:新粗纱
      let type = item.emp == '0' ? 'TXCSOML' : 'CUSHA';
      this.$parent.$parent.$parent.getInfoByDevSn(type, item.devSn);
      this.$refs.cushaDialog.showDialog(item);
    },
    clickHandleDl(item) {
      var getInfoQuary = this.dongLiMenu[item];
      var dialogData = this.dongLiItem[item];
      this.$parent.$parent.$parent.getInfoByDevSn('DONGLI', getInfoQuary);
      this.$refs.dongliDialog.showDialog(dialogData);
    }
  }
};
</script>

<style scoped></style>
